﻿using System;
using System.Collections.Generic;
using Abp.Utils;

namespace Abp.Web
{
    public class NavigationMenu
    {
        private static int sequenceNo = 1;
        public Guid Id { get; set; }

        public Guid? ParentId { get; set; }

        public string Name { get; set; }

        public string DisplyName { get; set; }

        public string UrlAddress { get; set; }

    

        public string Description { get; set; }

        public string Remark { get; set; }

        public string Style { get; set; }

        public string Target { get; set; }

        public int SequenceNo { get; set; }


        public List<NavigationMenu> Children { get; }

        public NavigationMenu()
        {
            this.Id = GuidUtils.SequentialGuid();
            this.SequenceNo = sequenceNo++;
            this.Target = NavigationMenuTarget.None;
            this.Children=new List<NavigationMenu>();
        }

        public NavigationMenu(string name, string style) : this()
        {
            this.Name = name;
            this.DisplyName = name;
            this.Style = style;
        }

        public NavigationMenu(string name, string style, string urlAddress) : this(name, style)
        {
            UrlAddress = urlAddress;
        }

        public NavigationMenu(string name, string style, string urlAddress, string target) : this(name, style, urlAddress)
        {
            Target = target;
        }

        public NavigationMenu AddChildren(string name,string style,string urlAddress)
        {
            NavigationMenu submenu = new NavigationMenu(name, style, urlAddress);
            submenu.ParentId = this.Id;
            this.Children.Add(submenu);
            return this;
        }
        public NavigationMenu AddChildren(string name, string style, string urlAddress,string target)
        {
            NavigationMenu submenu = new NavigationMenu(name, style, urlAddress, target);
            submenu.ParentId = this.Id;
            this.Children.Add(submenu);
            return this;
        }
    }

    public class NavigationMenuTarget
    {
        public const string Frame = "frame";

        public const string None = "none";

        public const string Dialog = "dialog";
    }

    public class ModuleType
    {
        public const int Menu = 1;

        public const int Button = 2;
    }
}
